package com.ht.medicaltreatment.viewmodel

import androidx.lifecycle.viewModelScope
import com.ht.medicaltreatment.bean.Page
import com.xgst.lib.http.ApiResult
import kotlinx.coroutines.launch

class SubjectsViewModel : BaseViewModel() {
    fun requestFormList(currentPage:Int,patientNameOrCodeOrCard:String,projectId:String,onSuccess:(MutableList<Page>?)->Unit,onError:(String)->Unit){
        viewModelScope.launch {
            val bean = mApi.subjectList("$currentPage",projectId,patientNameOrCodeOrCard,"10")
            when(bean){
                is ApiResult.Success -> onSuccess(bean.data.data?.pageList)
                is ApiResult.Error -> onError(bean.errorMessage)
            }
        }
    }
}
